﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Storage;
using Model;
using Model.Entity;
using System.Linq.Expressions;

namespace DAL.Interface
{
    /// <summary>
    /// 基础数据访问层接口(LONG)
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public interface IBaseDAL_LONG<T> where T : EntityBase_LONG
    {
        /// <summary>
        /// 获取基础上下文对象
        /// </summary>
        /// <returns></returns>
        DbContext GetBaseDBContext();
        /// <summary>
        /// 获取上下文对象
        /// </summary>
        /// <returns></returns>
        TianXiaHuiForumManagementSystemDbContext GetDBContext();
        /// <summary>
        /// 开始事务
        /// </summary>
        /// <returns></returns>
        Task<IDbContextTransaction> BeginTransactionAsync();
        /// <summary>
        /// 添加实体并返回
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task<T> AddEntityAndReturnAsync(T entity);
        /// <summary>
        /// 创建实体
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task<bool> AddEntityAsync(T entity);
        /// <summary>
        /// 删除实体
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task<bool> DeleteEntityAsync(T entity);
        /// <summary>
        /// 删除实体
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<bool> DeleteEntityAsync(long id);
        /// <summary>
        /// 编辑实体
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task<bool> EditEntityAsync(T entity);
        /// <summary>
        /// 获取所有实体
        /// </summary>
        /// <returns></returns>
        Task<IQueryable<T>> GetEntityAllAsync();
        /// <summary>
        /// 获取所有实体
        /// </summary>
        /// <param name="whereLambda"></param>
        /// <returns></returns>
        Task<IQueryable<T>> GetEntityAllAsync(Expression<Func<T, bool>> whereLambda);
    }
}
